package com.yuhang.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuhang.entity.HyRepairStream;
import com.yuhang.mapper.HyRepairStreamMapper;
import com.yuhang.service.HyRepairStreamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuhang
 * @since 2021-04-25
 */
@Service
public class HyRepairStreamServiceImpl extends ServiceImpl<HyRepairStreamMapper, HyRepairStream> implements HyRepairStreamService {

    @Autowired
    private HyRepairStreamMapper hyRepairStreamMapper;

    @Override
    public IPage<HyRepairStream> selectByPage1(int pageNum, int pageSize, String likeusername, String likerepairname, String likedevicename) {
        Page<HyRepairStream> page = new Page(pageNum,pageSize);
        QueryWrapper<HyRepairStream> qw = new QueryWrapper();
        if(likeusername!=null&&!likeusername.equals("")){
            qw.like("user_name",likeusername);
        }
        if(likerepairname!=null&&!likerepairname.equals("")){
            qw.like("repair_name",likerepairname);
        }
        if(likedevicename!=null&&!likedevicename.equals("")){
            qw.like("device_name",likedevicename);
        }
        IPage<HyRepairStream> iPage = hyRepairStreamMapper.selectPage(page,qw);
        return iPage;
    }

    @Override
    public IPage<HyRepairStream> selectByPage2(int pageNum, int pageSize, int userid,String likerepairname,String likedevicename) {
        Page<HyRepairStream> page = new Page(pageNum,pageSize);
        QueryWrapper<HyRepairStream> qw = new QueryWrapper();
        qw.eq("user_id",userid);
        if(likerepairname!=null&&!likerepairname.equals("")){
            qw.like("repair_name",likerepairname);
        }
        if(likedevicename!=null&&!likedevicename.equals("")){
            qw.like("device_name",likedevicename);
        }
        IPage<HyRepairStream> iPage = hyRepairStreamMapper.selectPage(page,qw);
        return iPage;
    }

    @Override
    public IPage<HyRepairStream> selectByPage3(int pageNum, int pageSize, String likedevicename) {
        Page<HyRepairStream> page = new Page(pageNum,pageSize);
        QueryWrapper<HyRepairStream> qw = new QueryWrapper();
        qw.eq("state",1);
        if(likedevicename!=null&&!likedevicename.equals("")){
            qw.like("device_name",likedevicename);
        }
        IPage<HyRepairStream> iPage = hyRepairStreamMapper.selectPage(page,qw);
        return iPage;
    }

    @Override
    public IPage<HyRepairStream> selectByPage4(int pageNum, int pageSize, int repairid, String likedevicename) {
        Page<HyRepairStream> page = new Page(pageNum,pageSize);
        QueryWrapper<HyRepairStream> qw = new QueryWrapper();
        qw.eq("repair_id",repairid);
        if(likedevicename!=null&&!likedevicename.equals("")){
            qw.like("device_name",likedevicename);
        }
        IPage<HyRepairStream> iPage = hyRepairStreamMapper.selectPage(page,qw);
        return iPage;
    }
}
